package com.example.cr.insect.controller.admin;

import com.example.cr.insect.dto.ChartDataDTO;
import com.example.cr.insect.service.ChartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/chart")
@CrossOrigin(origins = "*") // 处理跨域
public class ChartController {

    @Autowired
    private ChartService chartService;

    @GetMapping("/pest-trend")
    public ResponseEntity<ChartDataDTO> getPestTrend() {
        return ResponseEntity.ok(chartService.getChartData());
    }
}
